// WARNING: This file has been generated. Any manual changes must be made within preserved regions or they will be lost.

//===============================================================================
//
// FilesTests
//
// PURPOSE: 
// Tests the functionality of Files.
//
// NOTES: 
// 
//
//===============================================================================
//
// Copyright (C) 2003 Wallis Software Solutions
// All rights reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
// FITNESS FOR A PARTICULAR PURPOSE.
//
//===============================================================================

using System.IO;
using NUnit.Framework;

namespace Agile.Common.Common.Tests
{
    /// <summary>
    /// Tests the functionality of Files.
    /// </summary>
    [TestFixture]
    public class FilesTests
    {
        /// <summary>
        /// Verifies the clean outputs still works when there are read only files in the directory
        ///     - Create a test directory
        ///     - add a bin directory to the test directory
        ///     - Add a Debug directory to the din directory
        ///     - Create a test file in the debug directory that is read only
        ///     - Call Files.CleanOutputsIn for the test directory
        ///     - Check the bin directory has been deleted.
        ///     - Cleanup...delete the test directory
        /// </summary>
        [Test, Ignore("Need a better way to test, file in use error.")]
        public void CleanOutputsWithReadOnlyFileTest()
        {
            // Create a test directory
            var testDirectory =
                new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "TestCleanOutputsDirectory"));
            testDirectory.Create();
            // add a bin directory to the test directory
            var binDirectory = new DirectoryInfo(Path.Combine(testDirectory.FullName, "bin"));
            binDirectory.Create();
            // Add a Debug directory to the bin directory
            var debugDirectory = new DirectoryInfo(Path.Combine(binDirectory.FullName, "Debug"));
            debugDirectory.Create();
            // Create a test file in the debug directory that is read only
            var file = new FileInfo(Path.Combine(debugDirectory.FullName, "ReadOnlyTestFile"));
            file.Create();
            File.SetAttributes(file.FullName, FileAttributes.ReadOnly);

            // Call Files.CleanOutputsIn for the test directory
            Files.CleanOutputsIn(testDirectory);

            // Check the bin directory has been deleted.
            Assert.IsFalse(Directory.Exists(binDirectory.FullName), "Check the bin directory has been deleted.");
            // Cleanup...delete the test directory
            testDirectory.Delete();
        }
    }
}